package com.biz.primus.ms.payment.dao.po;

import com.biz.primus.base.enums.CommonStatus;
import com.biz.primus.ms.base.jpa.po.BaseEntity;
import java.util.List;
import javax.persistence.*;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Where;

/**
 * 商户
 */
@Entity
@Table(name = "merchant")
@Data
public class Merchant extends BaseEntity {

    private static final long serialVersionUID = 7345987835098586973L;

    /**
     * 名称
     */
    @Column(length = 40)
    private String name;

    /**
     * 商户状态
     */
    @Column
    @Convert(converter = CommonStatus.Converter.class)
    private CommonStatus status = CommonStatus.ENABLE;


    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "merchant")
    @Where(clause = "status='ENABLE'")
    private List<PaymentChannel> paymentChannels;

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    }

}